#include <stdio.h>
#include <string>
using namespace std;

#define N 210
#define debug false

int  lt, rt;
char ss[N], *ps;
char spec[N];
char fout[N];
int len;
string slist[N];

int tagtop;

void markoutsymbol(int i)
{
	while (ps[i]!='>')
		fout[i++] = 1;
	fout[i] = 1;
}

void tryright()
{
	int p;
	string stmp;
	tagtop = 0;
	p = rt +1;
	while (p<len)
	{
		if (spec[p]==-1) ++p;
		else
		{
			//stmp = slist[spec[p]];
			if (slist[spec[p]][1]!='/')  
			{
				tagtop++;
				while (ps[p]!='>' && p<len) p++;
				p++;
			}
			else if (tagtop>0)
			{
				tagtop--;
				while (ps[p]!='>' && p<len) p++;
				p++;
			}
			else
			{
				markoutsymbol(spec[p]);				
				while (ps[p]!='>' && p<len) p++;
				p++;
			}
		}
		
	}
}

void tryleft()
{ 
	int p;
	string stmp;
	tagtop = 0;
	p = lt-1;
	while (p>=0)
	{
		if (spec[p]==-1) --p;
		else 
		{
			//stmp = slist[spec[p]];
			if (slist[spec[p]][1]=='/')  
			{
				tagtop++;
				p = spec[p] - 1;
			}
			else if (tagtop>0)
			{
				tagtop--;
				p = spec[p] - 1;
			}
			else
			{
				markoutsymbol(spec[p]);
				p = spec[p] - 1;
			}
		}
	} // end of while 
}


void markout()
{
	int i;
	for (i=lt; i<rt; ++i)
		fout[i] = 1;
	tryleft();
	tryright();
}

inline void mark(int &i)
{
	int a = i;
	while (ps[i]!='>')
		spec[i++] = a;
	spec[i] = a;
	slist[a] = string(&ps[a], &ps[i+1]);
	//if (debug) 
	//	printf("Find signbol:%s\n", slist[a].c_str());
}

void markspec()
{
	int i;
	for (i=0; i<len; ++i)
	{
		if (ps[i]=='<') 
			mark(i);
	}
}

void deal()
{
	memset(spec, -1, sizeof(spec));
	memset(fout, 0, sizeof(fout));
	markspec();
	markout();
}

int in()
{
	gets(ss);
	if (strlen(ss)==0) gets(ss);
	sscanf(ss, "%d%d", &lt, &rt);
	if (lt == -1 && rt == -1) return 0;
	ps = ss;
	while (*ps==' ') ps++;
	while (*ps!=' ') ps++;
	while (*ps==' ') ps++;
	while (*ps!=' ') ps++;
	ps++;
	len = strlen(ps);
	if (debug)
		printf("The string is:%s\n", ps);
	return 1;
}

void output()
{
	int i;
	for (i=0; i<len; ++i)
		if (fout[i]) printf("%c", ps[i]);
	printf("\n");
}
int main()
{

	while (in())
	{
		deal();
		output();
	}
	return 0;
}

